package org.budo.spring.mvc.view.jphp.launcher;

import java.io.OutputStream;
import java.util.Properties;

import php.runtime.Memory;
import php.runtime.env.CompileScope;
import php.runtime.env.Environment;
import php.runtime.memory.StringMemory;

/**
 * @author li
 */
public abstract class AbstractJphpLauncher {
    private ClassLoader classLoader = this.getClass().getClassLoader();

    private CompileScope compileScope = new CompileScope();

    private Properties config=new Properties();

    private Environment environment;

    private OutputStream outputStream;

    public Memory getConfigValue(String key, Memory def) {
        String result = this.getConfig().getProperty(key);
        if (result == null)
            return def;

        return new StringMemory(result);
    }

    public Memory getConfigValue(String key, String def) {
        return this.getConfigValue(key, new StringMemory(def));
    }

    public OutputStream getOutputStream() {
        return outputStream;
    }

    public void setOutputStream(OutputStream outputStream) {
        this.outputStream = outputStream;
    }

    public Environment getEnvironment() {
        return environment;
    }

    public void setEnvironment(Environment environment) {
        this.environment = environment;
    }

    public Properties getConfig() {
        return config;
    }

    public void setConfig(Properties config) {
        this.config = config;
    }

    public CompileScope getCompileScope() {
        return compileScope;
    }

    public ClassLoader getClassLoader() {
        return classLoader;
    }

    public void setClassLoader(ClassLoader classLoader) {
        this.classLoader = classLoader;
    }
}